package com.mt.api.modules.controller;

import com.mt.common.response.WebResponse;
import com.mt.common.response.WebResponseUtils;
import com.mt.api.modules.domain.WxUserInfo;
import com.mt.api.modules.service.AppWeixinService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: plover
 * @Date: 2020/07/06/4:10 下午
 * @Description:
 */
@RestController
@RequestMapping("/app/wx")
public class AppWeixinController {


    @Autowired
    private AppWeixinService appWeixinService;

    @PostMapping("/login")
    public WebResponse login(String code) {
        if (StringUtils.isEmpty(code)) {
            return WebResponseUtils.errorParam("code参数不能为空");
        }
        return appWeixinService.login(code);
    }

    @PostMapping("/bind")
    public WebResponse updateUserInfo(@RequestBody WxUserInfo wxUserInfo) {
        return appWeixinService.bindUserInfo(wxUserInfo);
    }

}
